﻿{include file="public/header" /}
<body>

<div class="x-body">
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 5px;">
    <legend>订单明细</legend>
    <div class="layui-row">
      <div class="container-wrap">
        <div class="box-1">
          <table class="layui-table">
            <thead>
            <tr>
              <th>订单编号</th>
              <th>订单内容</th>
              <th>交货日期</th>
              <th>客户简称</th>
              <th>备料</th>
              <th>订单报价</th>
              <th>客户项目号</th>
              <th>完成</th>
              <th>发货</th>
              <th>收款</th>
              <th>评审</th>
              <th>建档时间</th>
              <th>报价</th>
            </tr>
            </thead>
            <tbody>
            {volist name="$orderRow" id="info"}
            <tr>
              <td> {$info.order_id}</td>
              <td>{$info.order_content}</td>
              <td>{$info.delivery_time}</td>
              <td>{$info.client_id}</td>
              <td>{$info.prepare}</td>
              <td>{$info.order_price}</td>
              <td>
                {$info.client_prj_id}
              </td>
              <td>
                {if $info.if_complete == 1}
                完成
                {else/}
                未完成
                {/if}
              </td>
              <td>
                {if $info.deliver_goods}
                已发货
                {else/}
                未发货
                {/if}
              </td>
              <td>
                {if $info.receivables == 1}
                已收款
                {else/}
                未收款
                {/if}
              </td>
              <td></td>
              <td>{$info.create_time}</td>

              <th>报价</th>
            </tr>
            {/volist}
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </fieldset>
  <xblock>
    <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>

    <button class="layui-btn"  onclick="openLinke('{$info.id}')"><i class="layui-icon"></i>添加</button>

    {if $model == 1}
    <a href="{:url('index/Order/orderDetail',['id'=>$id])}"><button class="layui-btn">隐藏</button></a>
    {else}
    <a href="{:url('index/Order/orderDetail',['id'=>$id,'model'=>'1'])}"><button class="layui-btn">显示</button></a>
    {/if}
    <button class="layui-btn" onclick ="x_admin_show('一键复制','{:url(\'index/Order/copyOrderDetail\',[\'id\'=>$id])}',500,400)">一键复制</button>
    <span class="x-right" style="line-height:40px">共条{$orderDatailInfoC} · 未显示 {$orderDatailInfoNoShow} 条 </span>
  </xblock>
    <div class="layui-row">
        <div class="container-wrap">
            <div class="box-1">
                {if !$actrion}
                <table class="layui-table" id="table0">
                    <td>
                        ID: <a data-id="" id="data_a" href="#" style="color: green"></a>   <span style="color: red">请点击左边有效数据</span>
                    </td>
                </table>
                {/if}
                <table class="layui-table">
                    <thead>
                    <tr>
                        {if $actrion}
                        <th>操作</th>
                        {else}
                        <th  onclick="openAll()">
                            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                        </th>
                        {/if}
                        <th>订单状态</th>
                        <th>序号</th>
                        <th>图纸明细</th>
                        <th>产品名称</th>
                        <th>材料</th>
                        <th>形状</th>
                        <th>热处理</th>
                        <th>单位</th>
                        <th>订单 / 计划 / 完成 / 发货 </th>
                        <!--<th>计划数量 </th>-->
                        <th>图纸工艺</th>
                        <th>加工内容</th>
                        <th>交货日期</th>
                        <th>完成状态</th>
                        <!--<th>入库数量</th>-->
                        <th>备注</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i = 1;?>
                    {volist name="orderDatailInfo" id="info"}
                    <tr>
                        <?php
                    $count = getCountExterna($info['drawing_externa_or_internal_id'],$info['order_id'],$info['if_tu']);
                  ?>

                        {if $actrion}
                        <td>
                            <a title="修改" onclick="x_admin_show('修改订单','{:url(\'index/Order/editOrderDetail\',[\'id\'=>$info.id])}',600,500)", href="javascript:;"><i style="color: green" class="layui-icon"></i></a>
                            <a title="删除" onclick="delete_(this,'{$info.id}')" href="javascript:void(0);" ><i  style="color:red;" class="layui-icon"></i></a>
                        </td>
                        {else}
                        <td onclick="openAll()">
                            <div class="layui-unselect layui-form-checkbox"  lay-skin="primary" data-id='{$info.id}'><i class="layui-icon">&#xe605;</i></div>
                        </td>
                        {/if}

                        <?php
             $isTask = getIsTask($info['id']);
             ?>
                        <td>
                            <button title="任务"   style="border: 0;background: transparent;cursor: pointer"  class="renwu" onclick="x_admin_show('订单任务','{:url(\'index/task/inTask\',[\'id\'=>$info.id])}')"
                                    {if $info.arrange =='否'}
                                    disabled
                                    {/if}
                            >

                            {if $info.arrange =='否'}
                            无需加工
                            {else}
                            {if $isTask}
                            <?php $wc = getWc($info['id']);?>
                            {if $wc == 1}
                            任务完成
                            {else}
                            已下任务
                            {/if}
                            {else/}
                            未下任务
                            {/if}
                            {/if}
                            <!--{if $info.arrange =='自加工'}-->
                            <!--{if $isTask}-->
                            <!--<?php $wc = getWc($info['id']);?>-->
                            <!--{if $wc == 1}-->
                            <!--完成-->
                            <!--{else}-->
                            <!--已下任务-->
                            <!--{/if}-->
                            <!--{else/}-->
                            <!--未下任务-->
                            <!--{/if}-->
                            <!--{else/}-->
                            <!--{if $info.arrange =='整体外协'}-->
                            <!--整体外协-->
                            <!--{elseif $info.arrange =='标件不加工'/}-->
                            <!--标件不加工-->
                            <!--{elseif $info.arrange =='外协完成'/}-->
                            <!--外协完成-->
                            <!--{/if}-->
                            <!--{/if}-->
                            </button>
                            <!--<a title="任务"  href="javascript:;" onclick="x_admin_show('下达任务','{:url(\'index/ProductTask/addProductTask\',[\'id\'=>$info.id])}',600,500)" >下任务</a>-->
                        </td>
                        <td>
                            {if $count }
                            <?php echo  $i ;?>  <a onclick="x_admin_show('添加订单明细','{:url(\'index/Order/newOrder\',[\'id\'=>$info.order_id,\'ex_or_id\'=>$info.drawing_externa_or_internal_id,\'type\'=>$info.if_tu])}',800,500)", href="javascript:;"><span style="color: red">新</span></a>
                            {else}
                            <?php echo  $i ;?>
                            {/if}
                            <span class="layui-table-sort layui-inline">
                   <i class="layui-edge layui-table-sort-asc" onclick="SanSort('{$info.id}','asc')"></i>
                   <i class="layui-edge layui-table-sort-desc"  onclick="SanSort('{$info.id}','desc')"></i>
                 </span>
                        </td>

                        <td>
                            {$info.drawing_detail_id|getDrawingDetailId}
                        </td>
                        <td>{$info.drawing_detail_id|getDrawingName}</td>
                        <?php $blueprintInfoList = getblueprintInfoList($info['drawing_detail_id']);?>
                        <td>{$blueprintInfoList.material|getMaterialType}</td>
                        <td>{$blueprintInfoList.material_type|getMateria}</td>
                        <td>{$blueprintInfoList.heat_treatment}</td>
                        <td>{$info.company} </td>
                        <?php $wangc =  getOrderOk($info['id']);
                              $fahuo =  getSonghuo($info['order_detail_code']);
                              $flag = 0;
                               if($wangc == $fahuo){
                               $flag = 1;
                               }
                               ?>
                        <td>{$info.order_qty} /  {$info.plan_qty} / <span {if $flag == 1} style="color: #28ac17" {/if}  ><?php echo getOrderOk($info['id']);?></span> /  [<span style="cursor: pointer" onclick="x_admin_show('送货单明细','{:url(\'index/Delivery/viewShow\')}'+'?model=1&order_detail_code='+'{$info.order_detail_code}')"><?php echo getSonghuo($info['order_detail_code']);?></span>]</td>
                        <!--<td>计划</td>-->
                        <td class="td-manage">
                            {if $blueprintInfoList.files_state==0||$blueprintInfoList.drawing_externa_id==""||!widget('Widget/drawing_check',['drawing_id'=>$blueprintInfoList.drawing_externa_id])}<!-- 不继承或者外图继承无效 -->
                            <button title="图纸" onclick="x_admin_show('图纸明细 <span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的图纸文件',
          '{:url(\'index/blueprint/is_DrawingFiles\',[\'id\'=>$blueprintInfoList.id,\'key\'=>\'wai\',\'drawing_num\'=>$blueprintInfoList.drawing_detail_id])}')" href="javascript:;">
                                <span class="layui-badge layui-bg-{:widget('Widget/files_check',['id'=>$blueprintInfoList.id,'tip'=>'abroad'])}">图</span></button>
                            {elseif $blueprintInfoList.files_state==1} <!-- 继承 -->
                            <button title="图纸" onclick="x_admin_show('图纸明细 <span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的图纸文件',
          '{:url(\'index/blueprint/is_outDrawing\',[\'id\'=>$blueprintInfoList.drawing_externa_id])}')" href="javascript:;"><span class="layui-badge layui-bg-orange">图</span></button>
                            {/if}
                            <button title="模型" onclick="x_admin_show('图纸明细 <span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的3d模型文件',
          '{:url(\'index/blueprint/is_DrawingFiles\',[\'id\'=>$blueprintInfoList.id,\'key\'=>\'nei\',\'drawing_num\'=>$blueprintInfoList.drawing_detail_id])}')" href="javascript:;"><span class="layui-badge layui-bg-{:widget('Widget/files_check',['id'=>$blueprintInfoList.id,'tip'=>'within'])}">3D</span></button>
                            <button title="程序单" onclick="x_admin_show('图纸明细 <span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的程序单文件',
          '{:url(\'index/blueprint/is_DrawingFiles\',[\'id\'=>$blueprintInfoList.id,\'key\'=>\'cheng\',\'drawing_num\'=>$blueprintInfoList.drawing_detail_id])}')" href="javascript:;"><span class="layui-badge layui-bg-{:widget('Widget/files_check',['id'=>$blueprintInfoList.id,'tip'=>'engineering'])}">程</span></button>
                            {if $blueprintInfoList.is_gongxu !=0}
                            <button title="工"  href="javascript:;" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的工艺信息','{:url(\'index/blueprint/process\',[\'drawing_detail_id\'=>$blueprintInfoList.drawing_detail_id])}')" ><span class="layui-badge layui-bg-green">工</span></button>
                            {else}
                            <button title="工"  href="javascript:;" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$blueprintInfoList.drawing_detail_id}</span> 的工艺信息','{:url(\'index/blueprint/process\',[\'drawing_detail_id\'=>$blueprintInfoList.drawing_detail_id])}')" ><span  class="layui-badge layui-bg-blue">工</span></button>
                            {/if}
                        </td>
                        <td>{$info.content}</td>
                        <td>{$info.date_delivery}</td>
                        <td>
                            {if $info.if_complete == 0 }
                            未完成
                            {else}
                            完成
                            {/if}
                        </td>
                        <!--<td>{$info.warehousing} 入库</td>-->
                        <td>{$info.remark}</td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="page">
            {$orderDatailInfo|raw}
        </div>
    </div>
</div>
<script>

    function openLinke(id) {
        layer.open({
            content: '选择你要进入的图纸类型～～'
            ,btn: ['外图', '内图'] //按钮
            ,yes: function(index, layero){
                //按钮【按钮一】的回调
                x_admin_show("外图",'{:url(\'index/blueprint/blueprintoutside\',[\'id\'=>1,'model'=>1,'order'=>$orderCode])}');
            },btn2: function(index, layero){
                //按钮【按钮二】的回调
                x_admin_show("内图",'{:url(\'index/internal/internalinfo\',[\'id\'=>1,'model'=>1,'order'=>$orderCode])}');
            },btn3: function(index, layero){
                //按钮【按钮三】的回调
                x_admin_show("总价报价","{:url('index/quoted/quotedInfoType3')}?id=" + id);
            }
            ,cancel: function(){
                //右上角关闭回调
            }
        });
    }

    function openAll () {
        var data = tableCheck.getData();
        to(data);
    }
    function to(data) {
        $("#data_a").attr('data-id',data);
        $("#data_a").text(data+" 已选"+data.length+"项");
        if(!data.length){
            $("#data_a").text("");
        }
    }
  function show(obj,id,show) {
      layer.confirm('确定要更改吗？',function(index){
          var url = "{:url('/index/Order/updateShow')}";
          var postData ={"id":id,"show":show};
          $.post(url,postData,function (result) {
              if(result == 1 ){
                  layer.alert("更改成功", {icon: 6},function () {
                      window.location.reload();  //刷新父级页面
                  });
              }else {
                  layer.alert("更改失败", {icon: 5});
              }
          },"json")
      });
  }
  function SanSort(id,sort) {
      $.ajax({
          url:"/index/Order/SanSort",
          type:"POST",
          dataType:"json",
          data:{
              id:id,
              sort:sort
          },
          success:function (res) {
              if(res.error === 1000 ){
                  layer.msg(res.msg, {icon: 5});
              }else if(res.error === 1) {
                  window.location.reload();  //刷新父级页面
              }else {
                  layer.msg(res.msg, {icon: 5});
              }
          },
      });
  }

    /*删除*/
    function delete_(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            var url = "{:url('/index/Order/deleteDetail')}";
            var postData ={"id":id};
            $.post(url,postData,function (result) {
                if(result === 1 ){
                    layer.alert("删除成功", {icon: 6},function () {
                        window.location.reload();  //刷新父级页面
                    });
                }else {
                    layer.alert("删除失败", {icon: 5});
                }
            },"json");
        });
    }


</script>
</body>
</html>